package com.meilingcloud.biobank.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.meilingcloud.biobank.domain.ShiftSample;
import com.meilingcloud.biobank.mapper.ShiftSampleMapper;
import com.meilingcloud.biobank.service.IShiftSampleService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 转移样本 Service业务层处理
 *
 * @author chenl
 * @date 2021-04-30
 */
@Service
public class ShiftSampleServiceImpl extends ServiceImpl<ShiftSampleMapper, ShiftSample> implements IShiftSampleService {

    @Override
    public List<ShiftSample> queryList(ShiftSample shiftSample) {
        LambdaQueryWrapper<ShiftSample> lqw = Wrappers.lambdaQuery();
        if (StringUtils.isNotBlank(shiftSample.getShiftId())) {
            lqw.eq(ShiftSample::getShiftId, shiftSample.getShiftId());
        }
        if (shiftSample.getOldTubeId() != null) {
            lqw.eq(ShiftSample::getOldTubeId, shiftSample.getOldTubeId());
        }
        if (shiftSample.getNewTubeId() != null) {
            lqw.eq(ShiftSample::getNewTubeId, shiftSample.getNewTubeId());
        }
        if (StringUtils.isNotBlank(shiftSample.getOldSampLocation())) {
            lqw.eq(ShiftSample::getOldSampLocation, shiftSample.getOldSampLocation());
        }
        if (StringUtils.isNotBlank(shiftSample.getNewSampLocation())) {
            lqw.eq(ShiftSample::getNewSampLocation, shiftSample.getNewSampLocation());
        }
        return this.list(lqw);
    }
}
